<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8"/>
	<title>{{ site_name }} filebox</title>
	<script type="text/javascript">
{% include "script.js" %}
	</script>
	<style type="text/css">
{% include "style.css" %}
	</style>
</head>
<body>
	<form action="upload/" method="POST" enctype="multipart/form-data">
		<input type="file" name="upload">
		<input type="submit" value="Upload">
		({{ email }}) <a href="{{ logout_url }}">Logout</a>
	</form>
	<br>{% if log %}<span style="color: {{ log.fore }}; background-color: {{ log.back }}; font-weight: bold;">{{ log.text }}</span>{% else %}<br>{% endif %}
	<table id="tableFiles">
		<tr onclick="tableClick(event);" onmouseover="columnHighlight(event, true);" onmouseout="columnHighlight(event, false);">
			{%- for header in headers %}
			<th>{{ header|safe }}</th>
			{%- endfor %}
		</tr>
		{%- set total = 0 %}
		{%- for file in files %}
		{%- set total = total + file.size %}
		<tr class="{{ loop.cycle('rowOdd', 'rowEven') }}">
			<td><a href="{{ file.name }}">{{ file.name }}</a></td>
			<td>{{ file.mime }}</td>
			<td>{{ file.size|intcomma }}</td>
			<td>{{ file.gets|intcomma }}</td>
			<td title="{{ file.when.strftime('%a, %d %b %Y %H:%M:%S') }}">{{ file.since() }}</td>
			<td><a href="delete/{{ file.name }}" id="delete_{{ file.name }}" onclick="return deleteFile(this);">delete</a></td>
			<td><a href="#" id="rename_{{ file.name }}" onclick="return renameFile(this);">rename</a></td>
		</tr>
		{%- if loop.last %}
		<tr class="{{ 'rowOdd' if loop.length is even else 'rowEven' }}">
			<td style="background-color: transparent !important;" colspan="{{ num_cols + 2 }}">{{ loop.length }} {{ 'file' if loop.length == 1 else 'files' }} ({{ total|intcomma }} bytes)</td>
		</tr>
		{%- endif %}
		{%- endfor %}
	</table>
</body>
</html>
